package com.design.movieticket.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.design.movieticket.dto.CinemaDto;
import com.design.movieticket.entity.Cinema;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface CinemaMapper extends BaseMapper<Cinema> {
    @Select("select id from cinema where principal = #{loginUser}")
    public long getCinemaByUsername(String loginUser);

    @Select("select username from user where id in (select user_id from user_role where role_id = 2)")
    List<String> getAdmin();


    @Select("select id,cinema_name,cinema_number,address from cinema where del_flag = 0")
    List<CinemaDto> wxGetCinemaList();

    @Select("SELECT id,cinema_name,cinema_number,address from cinema where id in " +
            "(SELECT DISTINCT cinema_id from movie_hall where id in " +
            "(SELECT DISTINCT movie_hall_id from movie_arrange where movie_name = #{movieName} " +
            "and start_time BETWEEN #{dayStart} and #{dayEnd}))")
    List<CinemaDto> wxGetCinemaListEqualsMovieId(String movieName, String dayStart, String dayEnd);
}
